﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraSplashScreen;
using Sumen.Business.Model.Presenter.Inventory;
using Sumen_Stock.LookAndFeel.Sumen_System;

namespace Sumen_Stock.LookAndFeel.Inventory
{
    public partial class Frm_History_Product : DevExpress.XtraEditors.XtraForm
    {

        private InventoryPresenter _inventoryPresenter;

        #region Form

        public Frm_History_Product()
        {
            InitializeComponent();
            _inventoryPresenter = new InventoryPresenter();
            dateBegin.DateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            dateEnd.DateTime = dateBegin.DateTime.AddMonths(1).AddMinutes(-1);
        }

        public override void Refresh()
        {
            base.Refresh();
            LoadFrom();
        }

        #endregion


        #region Button event

        private void btnView_Click(object sender, EventArgs e)
        {
            LoadFrom();
        }

        private void btnExcel_Click(object sender, EventArgs e)
        {

        }

        private void btnPrint_Click(object sender, EventArgs e)
        {

        }
        #endregion


        #region Method

        void LoadFrom()
        {
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            List<object> id = popupTreeDM.ChildListPrimaryKey;
            //phải load hết category con
            gridControl1.DataSource = _inventoryPresenter.GetHistoryProduct(id, dateBegin.DateTime, dateEnd.DateTime).First();
            gridView1.BestFitColumns();
            gridView1.ExpandAllGroups();
            SplashScreenManager.CloseForm();
        }

        #endregion











    }
}